package j03sort;

import java.util.Arrays;

public class J03Bublle {
    public static void main(String[] args) {
        //{67, 42, 88, 16, 25, 3}
        //{42, 67, 88, 16, 25, 3}
        //{42, 67, 16, 25, 3, 88}
        //{42, 16, 25, 3, 67, 88}
        /*
        小 - 大
        两两比较
         */
        int[] arr = {67, 42, 88, 16, 25, 3};
        //{67, 42, 16, 25, 3，88}
        //大循环，归位的次数
        for (int i = 1; i <= arr.length-1; i++) {
            //i=0,arr.length-2
            //i=0,arr.length-2-i+1
//            for (int j = 0; j <= arr.length-2-i+1; j++) {
            for (int j = 0; j <= arr.length-1-i; j++) {
                if(arr[j+1]<arr[j]){
                    //发现后面的更小
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
